/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jfs.beans;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Mateusz
 */
@Entity
@Table(name = "impreza")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Impreza.findAll", query = "SELECT i FROM Impreza i"),
    @NamedQuery(name = "Impreza.findById", query = "SELECT i FROM Impreza i WHERE i.id = :id"),
    @NamedQuery(name = "Impreza.findByMiasto", query = "SELECT i FROM Impreza i WHERE i.miasto = :miasto"),
    @NamedQuery(name = "Impreza.findByDataimprezy", query = "SELECT i FROM Impreza i WHERE i.dataimprezy = :dataimprezy"),
    @NamedQuery(name = "Impreza.findByOpis", query = "SELECT i FROM Impreza i WHERE i.opis = :opis"),
    @NamedQuery(name = "Impreza.findByOrganizator", query = "SELECT i FROM Impreza i WHERE i.organizator = :organizator"),
    @NamedQuery(name = "Impreza.findByNazwa", query = "SELECT i FROM Impreza i WHERE i.nazwa = :nazwa")})
public class Impreza implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    //@NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Miasto")
    private String miasto;
    @Column(name = "Data_imprezy")
    @Temporal(TemporalType.DATE)
    private Date dataimprezy;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "Opis")
    private String opis;
    @Size(max = 200)
    @Column(name = "Organizator")
    private String organizator;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Nazwa")
    private String nazwa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idImpreza")
    private Collection<Bilet> biletCollection;

    public Impreza() {
    }

    public Impreza(Integer id) {
        this.id = id;
    }

    public Impreza(Integer id, String miasto, String opis, String nazwa) {
        this.id = id;
        this.miasto = miasto;
        this.opis = opis;
        this.nazwa = nazwa;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getMiasto() {
        return miasto;
    }

    public void setMiasto(String miasto) {
        this.miasto = miasto;
    }

    public Date getDataimprezy() {
        return dataimprezy;
    }

    public void setDataimprezy(Date dataimprezy) {
        this.dataimprezy = dataimprezy;
    }

    public String getOpis() {
        return opis;
    }

    public void setOpis(String opis) {
        this.opis = opis;
    }

    public String getOrganizator() {
        return organizator;
    }

    public void setOrganizator(String organizator) {
        this.organizator = organizator;
    }

    public String getNazwa() {
        return nazwa;
    }

    public void setNazwa(String nazwa) {
        this.nazwa = nazwa;
    }

    @XmlTransient
    public Collection<Bilet> getBiletCollection() {
        return biletCollection;
    }

    public void setBiletCollection(Collection<Bilet> biletCollection) {
        this.biletCollection = biletCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Impreza)) {
            return false;
        }
        Impreza other = (Impreza) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jfs.beans.Impreza[ id=" + id + " ]";
    }
    
}
